﻿namespace WMS6.Web.Customs
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class ExportDeclarationsQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlDeclarationsDate;
        protected DropDownList ddlDeclarationsIDOper;
        protected DropDownList ddlDeclarationsType;
        protected DropDownList ddlDeclarationsTypeOper;
        protected DropDownList ddlOrderIDOper;
        protected DropDownList ddlOwnerIDOper;
        protected DropDownList ddlStatus;
        protected DropDownList ddlStatusOper;
        protected HtmlForm F79820;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img1;
        protected HtmlImage img2;
        protected HtmlImage imgOrderID;
        protected HtmlImage imgOwnerID;
        protected Label lblDeclarationsDate;
        protected Label lblDeclarationsID;
        protected Label lblDeclarationsType;
        protected Label lblOrderID;
        protected Label lblOwnerID;
        protected Label lblQuery;
        protected Label lblStatus;
        protected HtmlLink mycss;
        protected TextBox txtDeclarationsDate;
        protected TextBox txtDeclarationsDate2;
        protected TextBox txtDeclarationsID;
        protected TextBox txtOrderID;
        protected TextBox txtOwnerID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("ExportDeclarationsList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("ExportDeclarationsList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void ddlDeclarationsType_TextChanged(object sender, EventArgs e)
        {
            if (this.ddlDeclarationsType.SelectedValue == "CR")
            {
                this.lblOrderID.Text = "核放单号";
                this.imgOrderID.Visible = false;
            }
            else
            {
                this.lblOrderID.Text = "出库单号";
                this.imgOrderID.Visible = true;
            }
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlDeclarationsIDOper, 0);
            base.InitQueryDDL(this.ddlDeclarationsTypeOper, 0);
            base.BindData2DDLBySysCode(this.ddlDeclarationsType, "CustomsType");
            base.BindData2DDLBySysCode(this.ddlStatus, "CustomsStatus");
            base.InitQueryDDL(this.ddlStatusOper, 0);
            base.InitQueryDDL(this.ddlOrderIDOper, 0);
            base.InitQueryDDL(this.ddlOwnerIDOper, 0);
            base.InitQueryDDL(this.ddlDeclarationsDate, 1);
            this.ddlDeclarationsType.Items.Insert(0, new ListItem("-----", ""));
            this.ddlDeclarationsTypeOper.SelectedValue = "Same As";
            this.ddlStatus.Items.Insert(0, new ListItem("-----", ""));
            this.ddlStatusOper.SelectedValue = "Same As";
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
                this.InitDropDownLists();
            }
        }

        public string DeclarationsDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDeclarationsDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDeclarationsDate.Text.Trim(), this.ddlDeclarationsDate.SelectedValue, this.txtDeclarationsDate2.Text.Trim(), "DeclarationsDate");
                }
                return "";
            }
        }

        public string DeclarationsID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDeclarationsID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDeclarationsID.Text.Trim(), this.ddlDeclarationsIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string DeclarationsType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlDeclarationsType.SelectedValue))
                {
                    return base.GetParamsString(this.ddlDeclarationsType.SelectedValue, this.ddlDeclarationsTypeOper.SelectedValue);
                }
                return "";
            }
        }

        public string OrderID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOrderID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOrderID.Text.Trim(), this.ddlOrderIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlStatus.SelectedValue))
                {
                    return base.GetParamsString(this.ddlStatus.SelectedValue, this.ddlStatusOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

